Setting up DHCP client
Note: This is a basic demonstration for educational purposes. In a real network environment, DHCP servers typically serve multiple clients on a network.
-
Install DHCP Server: First, you'll need to install a DHCP server package if it's not already installed on your Linux system.
-
Start the DHCP Server: Before you work with client make sure your DHCP server is running. To start the DHCP server service use the following command:
sudo systemctl start isc-dhcp-server
-
Configure a DHCP Client: Configure a network interface to use DHCP:
sudo nano /etc/network/interfaces
Edit the file to look like this (assuming the interface is named "eth0"):
auto eth0
iface eth0 inet dhcpSave the file and exit the text editor.
-
Restart the Network Service: To apply the DHCP configuration changes, restart the network service:
sudo systemctl restart networking
-
Monitor DHCP Server Logs: You can monitor the DHCP server logs to see lease assignments and client interactions. Use the following command to view the DHCP server logs in real-time:
sudo tail -f /var/log/syslog | grep dhcpd
-
Request an IP Address: You can manually trigger your Linux machine to request an IP address from the DHCP server by renewing its DHCP lease:
sudo dhclient -r # Release the current lease
sudo dhclient # Request a new leaseCheck the logs to see the DHCP lease assignment.